/*
 * GeoVISTA Center (Penn State, Dept. of Geography)
 * Copyright (c), 2003-2011,  Jin Chen and Alan M. MacEachren, GeoVISTA Center, Penn State University
 * Licensed under Simplified BSD License
 *
 *
 * @author: jin Chen 
 * @date: May 13, 2005$
 * @version: 1.0
 */
package edu.psu.geovista.app.pcp.plot.services;


public class DfCorrelationResult implements CorrelationResult,Comparable {
    //primaryVariable, secondVariable: the name of 2 variables based on which correlation is compute
    String primaryVariable;//  Usually u want to compute correlation btw a primary variable and a list other variables and u get a list of  DfCorrelationResult
    String secondVariable;
    double value;
    int numOfInvalid;//number of invalid data

    public DfCorrelationResult() {
    }

    public DfCorrelationResult(double value) {
        this.value = value;
    }

    public DfCorrelationResult(double value, int numOfInvalid) {
        this.value = value;
        this.numOfInvalid = numOfInvalid;
    }

    public double getValue() {
        return value;
    }

    public void setValue(double value) {
        this.value = value;
    }

    public int getNumOfInvalid() {
        return numOfInvalid;
    }

    public void setNumOfInvalid(int numOfInvalid) {
        this.numOfInvalid = numOfInvalid;
    }

    public String getPrimaryVariable() {
        return primaryVariable;
    }

    public void setPrimaryVariable(String primaryVariable) {
        this.primaryVariable = primaryVariable;
    }

    public String getSecondVariable() {
        return secondVariable;
    }

    public void setSecondVariable(String secondVariable) {
        this.secondVariable = secondVariable;
    }
    /**
         * can be sorted based on  correlationValue. The large value, the smaller index in the sorted list
         * @param o
         * @return
         */
        public int compareTo(Object o) {
            DfCorrelationResult cr=(DfCorrelationResult) o;
        double itsvalue = Math.abs(cr.getValue());
        double myvalue = Math.abs(this.getValue());
        if(itsvalue>myvalue ){
                return 1;
            }
            else if (cr.getValue()==this.getValue()){
                return 0;
            }
            else{
                return -1;
            }
        }
}
